using UnityEngine;
using System.Collections;

public class PlayerProjectileAttack : Attack {

    //Might be temp, depending how we do animations
    public float totalAnimationLifetime;
    public float animationLifetimeRemaining;
	public float animationSpeed = 0.18f;

    public bool goodGuy;

    protected float lifetime;
	
	public Vector3 velocity;

	// Use this for initialization
	void Start () {
		//Debug.Log (offset, this);
        animationLifetimeRemaining = totalAnimationLifetime;
		
		InitializeAnimationList();
        if (goodGuy)
            AddAnimation("animate", 0, 0, 3, animationSpeed);
        else
            AddAnimation("animate", 0, 0, 0, animationSpeed);
		StartAnimation("animate", true);
        lifetime = 0.0f;
	}
	
	// Update is called once per frame
	protected override void Update () {
        lifetime += Time.deltaTime;

        animationLifetimeRemaining -= Time.deltaTime;
        if (animationLifetimeRemaining <= 0.0f)
        {
            DestroyAttack();
        }
		
		transform.localPosition += velocity * Time.deltaTime;
		
		base.Update ();
	}
	
	protected override void OnTriggerEnter(Collider other)
    {
		base.OnTriggerEnter(other);
		DestroyAttack();
    }
}
